﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
using System;

namespace LazyFramework.Game
{
    public class ActorManager : Singleton<ActorManager>
    {
        public void CreateActor()
        {
            TaskManager.TaskState ts = TaskManager.CreateTask(LoadActor());
            ts.Start();
        }

        IEnumerator LoadActor()
        {
            ResourceRequest rq = Resources.LoadAsync<GameObject>("GameObjectActor");
            yield return rq;
            UnityEngine.Object ob = UnityEngine.Object.Instantiate(rq.asset);
            GameObject actor = ob as GameObject;
           // ActorBaseComponent abc = actor.AddComponent<ActorBaseComponent>();
            
            actor.transform.localScale = Vector3.one;
            actor.transform.localRotation = Quaternion.identity;
            actor.SetActive(true);
        }

        

        private T CreateClass<T>(string type) where T : ActorBaseSystem, new()
        {
            T tInstance = (T)World.Active.CreateSystem(Type.GetType(type, true));
            return tInstance;
        }
    }
  
}
